Filling the missing gaps(Sql Server 2005) [Set based using recursive CTE]

Posted by Thinking on Stack Overflow See other posts from Stack Overflow or by Thinking
Published on 2010-04-12T05:14:43Z Indexed on 2010/04/12 5:23 UTC
Read the original article Hit count: 404

Filed under:
|

I have a table

MissingData

1
10
NULL
NULL
22
NULL

The desired output will be

MissingData

1
10
10
10
22
22

i.e. the nulls will be filled up by the previous value until a new value is appearing.

I can solve this by using loop but my requirement is to solve it by CTE in which I am not so comfortable as of now.

Thanks

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sqlserver2005